<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>tabmorphi</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="tabmorphak.html" title="tabmorphak" />
    <link rel="next" href="tabplay.html" title="tabplay" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">tabmorphi</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="tabmorphak.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="tabplay.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="tabmorphi"></a>
      <div class="titlepage"></div>
      <a id="IndexTabmorphi" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">tabmorphi</span>
        </h2>
        <p>tabmorphi — 
      Allow morphing between a set of tables with interpolation.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp157342240"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>tabmorphi</em></span> allows morphing between a set of tables of the same size, by means of a weighted average between two currently selected tables.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp157343920"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">kout <span class="command"><strong>tabmorphi</strong></span> kindex, kweightpoint, ktabnum1, ktabnum2, \
      ifn1, ifn2 [, ifn3, ifn4, ..., ifnN]</pre>
      </div>
      <div class="refsect1">
        <a id="idp157346160"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifn1, ifn2 [, ifn3, ifn4, ..., ifnN]</em></span> - function table numbers. This is a set of chosen tables the user want to use in the morphing. All tables must have the same length. Be aware that only two of these tables can be chosen for the morphing at one time. Since it is possible to use non-integer numbers for the <span class="emphasis"><em>ktabnum1</em></span> and <span class="emphasis"><em>ktabnum2</em></span> arguments, the morphing is the result from the interpolation between adjacent consecutive tables of the set.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp157349056"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kout</em></span> - The output value for index <span class="emphasis"><em>kindex</em></span>, resulting from morphing two tables (see below).
    </p>
        <p>
      <span class="emphasis"><em>kindex</em></span> - main index index of the morphed resultant table. The range is 0 to table_length (not included).
    </p>
        <p>
      <span class="emphasis"><em>kweightpoint</em></span> - the weight of the influence of a pair of selected tables in the morphing. The range of this argument is 0 to 1. A zero makes it output the first table unaltered, a 1 makes it output the second table of the pair unaltered. All intermediate values between 0 and 1 determine the gradual morphing between the two tables of the pair.
    </p>
        <p>
      <span class="emphasis"><em>ktabnum1</em></span> - the first table chosen for the morphing. This number doesn’t express the table number directly, but the position of the table in the set sequence (starting from 0 to N-1). If this number is an integer, the corresponding table will be chosen unaltered. If it contains fractional values, then an interpolation with the next adjacent table will result.
    </p>
        <p>
      <span class="emphasis"><em>ktabnum2</em></span> - the second table chosen for the morphing. This number doesn’t express the table number directly, but the position of the table in the set sequence (starting from 0 to N-1). If this number is an integer, corresponding table will be chosen unaltered. If it contains fractional values, then an interpolation with the next adjacent table will result.
    </p>
        <p>
      The <span class="emphasis"><em>tabmorphi</em></span> family of opcodes is similar to the <a class="link" href="table.html" title="table"><em class="citetitle">table</em></a> family, but allows morphing between two tables chosen into a set of tables. Firstly the user has to provide a set of tables of equal length (ifn2 [, ifn3, ifn4, ..., ifnN]). Then he can choose a pair of tables in the set in order to perform the morphing: <span class="emphasis"><em>ktabnum1</em></span> and <span class="emphasis"><em>ktabnum2</em></span> are filled with numbers (zero represents the first table in the set, 1 the second, 2 the third and so on). Then determine the morphing between the two chosen tables with the <span class="emphasis"><em>kweightpoint</em></span> parameter. After that the resulting table can be indexed with the <span class="emphasis"><em>kindex</em></span> parameter like a normal <span class="emphasis"><em>table</em></span> opcode. If the value of this parameter surpasses the length of tables (which must be the same for all tables), then it is wrapped around.
    </p>
        <p>
      <span class="emphasis"><em>tabmorphi</em></span> is identical to <a class="link" href="tabmorph.html" title="tabmorph"><em class="citetitle">tabmorph</em></a>, but it performs linear interpolation for non-integer values of <span class="emphasis"><em>kindex</em></span>, much like <a class="link" href="tablei.html" title="tablei"><em class="citetitle">tablei</em></a>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp157364240"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the tabmorphi opcode. It uses the file <a class="ulink" href="examples/tabmorphi.csd" target="_top"><em class="citetitle">tabmorphi.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp157366096"></a>
          <p class="title">
            <strong>Example 912. Example of the tabmorphi opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac    <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o tabmorphi.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

giSine   <span class="ohdr">ftgen</span> 0, 0, 8193, 10, 1				<span class="comment">;sine wave</span>
giSquare <span class="ohdr">ftgen</span> 0, 0, 8193, 7, 1, 4096, 1, 0, <span class="op">-</span>1, 4096, <span class="op">-</span>1	<span class="comment">;square wave</span>
giTri    <span class="ohdr">ftgen</span> 0, 0, 8193, 7, 0, 2048, 1, 4096, <span class="op">-</span>1, 2048, 0	<span class="comment">;triangle wave</span>
giSaw    <span class="ohdr">ftgen</span> 0, 0, 8193, 7, 1, 8192, <span class="op">-</span>1			<span class="comment">;sawtooth wave, downward slope</span>

<span class="oblock">instr</span>    1

iamp   <span class="op">=</span> .7
kindex <span class="opc">phasor</span> 440			<span class="comment">;read table value at this index</span>
kindex <span class="op">=</span> kindex<span class="op">*</span>8192			<span class="comment">;for all 8192 index points</span>
kweightpoint <span class="op">=</span> 0.5			<span class="comment">;set weightpoint</span>
ktabnum1 <span class="opc">line</span> 0, p3, 3			<span class="comment">;morph through all tables</span>
ktabnum2 <span class="op">=</span> 2				<span class="comment">;set to triangle wave</span>
ksig <span class="opc">tabmorphi</span> kindex, kweightpoint, ktabnum1, ktabnum2, giSine, giSquare, giTri, giSaw
ksig <span class="op">=</span> ksig<span class="op">*</span>iamp
asig <span class="opc">interp</span> ksig			<span class="comment">;convert to audio signal</span>
<span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span>1 0 5
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp157370384"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="table.html" title="table"><em class="citetitle">table</em></a>,
      <a class="link" href="tabmorph.html" title="tabmorph"><em class="citetitle">tabmorph</em></a>,
      <a class="link" href="tabmorpha.html" title="tabmorpha"><em class="citetitle">tabmorpha</em></a>,
      <a class="link" href="tabmorphak.html" title="tabmorphak"><em class="citetitle">tabmorphak</em></a>,
      <a class="link" href="ftmorf.html" title="ftmorf"><em class="citetitle">ftmorf</em></a>,
    </p>
      </div>
      <div class="refsect1">
        <a id="idp157376304"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
        <p>New in version 5.06</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="tabmorphak.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="tabplay.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">tabmorphak </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> tabplay</td>
        </tr>
      </table>
    </div>
  </body>
</html>
